<?php
class testActions extends framework {
    public function actionsIndex() {
        $t = '0.760304' . time ();
        $url = 'http://jkbb.zgwhfe.com/Tools/VotingUpload.ashx';
        $code = 'http://jkbb.zgwhfe.com/Tools/VerifyCodeImage.ashx?time=' . $t;
        $chekc = 'http://jkbb.zgwhfe.com/Tools/getVCode.ashx';
        framework::plugin ( 'Valite' );
        
        
        $img = $this->curlRequest ( $code );
        $png = HIGHPHP_WEB_PATH . 'img/t.png';
        file_put_contents ( $png, $img );
        $valite = new valite (); 
        $valite->setImage ( $png );
        $valite->getHec ();
        $valite->Draw ();
        while ( @$str = fread ( STDIN, 1000 ) ) {
            echo "you print:" . $str;
            if (trim ( $str )) {
                if (intval ( $str ) > 1000) {
                                       
                    echo "$url\n";
                    print_r ( $this->curlRequest ( $url, array ('rnd' => $t, 'myid' => 15421, 'myip' => '183.62.140.1' . mt_rand ( 10, 99 ), 'mycheck' => $str, 'ajax' => 1 ) ) );
                    echo "\n";
                }
            }
        }
        return false;
    }
    
    public function curlRequest($url, $postdata = '', $cookieFile = 'ASP.NET_SessionId') {
        
        $ch = curl_init ();
        $option = array (CURLOPT_URL => $url, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1,CURLOPT_TIMEOUT=>5 );
       
        if ($cookieFile) {
            $option [CURLOPT_COOKIEJAR] = $cookieFile;
            $option [CURLOPT_COOKIEFILE] = $cookieFile;
        }
        if ($postdata) {
            if (@$postdata ['ajax']) {
                $option [CURLOPT_HTTPHEADER] = array ('X-Requested-With: XMLHttpRequest');
                unset ( $postdata ['Referer'] );
                unset ( $postdata ['ajax'] );
            }
            $option [CURLOPT_POST] = 1;
            $option [CURLOPT_POSTFIELDS] = $postdata;
            print_r($postdata);
        
        }
        
        curl_setopt_array ( $ch, $option );
        $response = curl_exec ( $ch );
        curl_close ( $ch );
        //echo $response;
        return $response;
    }
}